Dart Runes operator ==
Syntax & Examples


Runes.operator == operator

The `==` operator in Dart checks for equality between two objects.


Syntax of Runes.operator ==

The syntax of Runes.operator == operator is:

operator ==(dynamic other) → bool

This operator == operator of Runes the equality operator.

Parameters

ParameterOptional/RequiredDescription
otherrequiredThe object to compare with.


✐ Examples

1 Comparing runes 'a' and 'a'

In this example,

  1. We create two Rune objects rune1 and rune2 with the same character 'a'.
  2. We use the == operator to compare rune1 and rune2.
  3. We print the result which is true because both runes are equal.

Dart Program

void main() {
  Rune rune1 = Rune('a');
  Rune rune2 = Rune('a');
  bool result = rune1 == rune2;
  print(result);
}

Output

true

2 Comparing ASCII and character runes

In this example,

  1. We create two Rune objects rune1 and rune2 with the character 'A', one using the ASCII value and the other directly as a character.
  2. We use the == operator to compare rune1 and rune2.
  3. We print the result which is true because both runes are equal.

Dart Program

void main() {
  Rune rune1 = Rune(65);  // 'A' in ASCII
  Rune rune2 = Rune('A');
  bool result = rune1 == rune2;
  print(result);
}

Output

true

3 Comparing different character runes

In this example,

  1. We create two Rune objects rune1 and rune2 with the characters 'a' and 'b' respectively.
  2. We use the == operator to compare rune1 and rune2.
  3. We print the result which is false because the runes are not equal.

Dart Program

void main() {
  Rune rune1 = Rune('a');
  Rune rune2 = Rune('b');
  bool result = rune1 == rune2;
  print(result);
}

Output

false

Summary

In this Dart tutorial, we learned about operator == operator of Runes: the syntax and few working examples with output and detailed explanation for each example.